home *** CD-ROM | disk | FTP | other *** search
- /*
- * This program sends a form feed or a line feed to the printer.
- */
-
- #include "exec/types.h"
- #include "exec/io.h"
- #include "exec/memory.h"
- #include "libraries/dos.h"
- #include "intuition/intuition.h"
- #include "print.h"
-
- extern struct Window *OpenWindow();
- long IntuitionBase=0;
- struct Window *window;
-
- main()
- {
- ULONG class;
- USHORT gnum;
- char *ff,*lf;
- int l,file;
-
- struct IntuiMessage *message;
- struct Gadget *gadget_ptr;
-
- if (!(IntuitionBase = OpenLibrary("intuition.library",0))) exit(1);
- if (!(window = OpenWindow(&NewWindowStructure)))
- {
- cleanitup();
- exit(2);
- }
-
- ff = "\f";
- lf = "\n";
- do
- {
- WaitPort(window->UserPort);
- while( (message = (struct IntuiMessage *)
- GetMsg(window->UserPort) ) != NULL)
- {
- class = message->Class;
- gadget_ptr = (struct Gadget *) message->IAddress;
- if (class == GADGETUP) gnum = gadget_ptr->GadgetID;
- ReplyMsg(message);
- if ( class == CLOSEWINDOW )
- {
- cleanitup();
- exit(0);
- }
- if (( class == GADGETUP) && (gnum == 4))
- {
- file = Open("prt:",MODE_NEWFILE);
- l = Write(file,ff,1);
- Close(file);
- }
- if (( class == GADGETUP) && (gnum == 5))
- {
- file = Open("prt:",MODE_NEWFILE);
- l = Write(file,lf,1);
- Close(file);
- }
- }
- } while (1);
- }
-
- cleanitup() /* release allocated resources */
- {
- if (window) CloseWindow(window);
- CloseLibrary(IntuitionBase);
- }
-